export const numberDance = (id, end, step=4, format=true,  start=0) => {
    const node = document.getElementById(id)
    let n = start
    const timerID = setInterval(() => {
        n += step
        format ? node.innerHTML = formatting(n) : node.innerHTML = n
        if (n >= end) {
            clearInterval(timerID)
            format ? node.innerHTML = formatting(end) : node.innerHTML = end
        }
    }, 1)
}

function formatting(num) {
    num += ''
    return num.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
}
